<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>禅道用例导入工具</title>
    <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/import.css') }}">
</head>
<body>
    <!-- 顶部的访问入口，添加 id 以便后续更新链接 -->
    <a href="{{ xmind_url }}" id="xmind2testcase-link" class="top-link">访问xmind2testcase工具</a>
    <div class="container">
       <h1>禅道用例导入工具</h1>
        <form id="import-form" action="/start" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="zentao_url">禅道地址:</label>
                <input type="text" id="zentao_url" name="zentao_url" value="{{ zentao_url }}" required>
            </div>
            <div class="hint">
                例：http://127.0.0.1/zentao/api.php/v1<br>
                （请确保地址以http://或https://开头）
            </div>
            <div class="form-group">
                <label for="account">禅道账号:</label>
                <input type="text" id="account" name="account" required>
            </div>
            <div class="form-group">
                <label for="password">密码:</label>
                <input type="password" id="password" name="password" required>
            </div>
            <div class="form-group" id="product-id-group">
                <label for="product_id">产品ID:</label>
                <div class="input-group" style="flex:1;">
                    <input type="text" id="product_id" name="product_id" required>
                    <button type="button" onclick="window.location.href='/product-query'">产品ID查询</button>
                </div>
            </div>
            <div class="file-group">
                <label for="csv_file">CSV文件:</label>
                <input type="text" id="csv_file_text" placeholder="请选择CSV文件..." readonly>
                <input type="file" id="csv_file" name="csv_file" accept=".csv" required>
                <button type="button" id="choose-file">选择文件</button>
            </div>
            <button type="submit" class="submit-btn">开始导入</button>
        </form>
    </div>

    <!-- 右下角的修改配置按钮 -->
    <button id="config-btn">修改配置</button>

    <!-- 配置弹窗 -->
    <div id="config-modal" class="modal">
        <div class="modal-content">
            <span class="close-btn" id="config-close">&times;</span>
            <h2>修改配置</h2>
            <div class="modal-field">
                <label for="config-zentao-url">默认禅道URL:</label>
                <input type="text" id="config-zentao-url" value="{{ zentao_url }}">
            </div>
            <div class="modal-field">
                <label for="config-xmind-url">xmind2testcase入口URL:</label>
                <input type="text" id="config-xmind-url" value="{{ xmind_url }}">
            </div>
            <div class="modal-actions">
                <button id="config-reset" type="button">重置</button>
                <button id="config-save" type="button">保存</button>
                <button id="config-cancel" type="button">取消</button>
            </div>

        </div>
    </div>

    <script src="{{ url_for('static', filename='js/import.js') }}"></script>
</body>
</html>
